package com.huike.game;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

import com.huike.game.adapter.GvAdapter;
import com.huike.game.common.Common;

import java.util.ArrayList;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity  {

    private GridView gridView;
    private ArrayList<String> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        list = new ArrayList<>();
        for (int i = 1; i <= 6; i++){
            list.add("第" + i + "题(改)");
        }
        for (int i = 1; i <= 64; i++){
            list.add("第" + i + "题(编)");
        }
        for (int i = 1; i < 6; i++) {
            list.add("第" + i + "题(扩)");
        }

        gridView = findViewById(R.id.gv);//找到视图id
        gridView.setAdapter(new GvAdapter(list,MainActivity.this));

        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Common common = new Common() {
                    @Override
                    public void setActivity(Object o) {//重写跳转方法
                        startActivity(new Intent(MainActivity.this, (Class<?>) o));
                    }
                };
                common.toPage(i);//调用调转方法
            }
        });
    }



}
